package com.ysd.modules.sys.service.impl;

import com.ysd.modules.app.dao.StudentDao;
import com.ysd.modules.sys.dao.OptionsRecordSysDao;
import com.ysd.modules.sys.entity.Chapter;
import com.ysd.modules.sys.entity.OptionsRecord;
import com.ysd.modules.sys.entity.SolveTopicVO;
import com.ysd.modules.sys.service.OptionsRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dapeng
 * @since 2021-07-15
 */
@Service
public class OptionsRecordServiceImpl extends ServiceImpl<OptionsRecordSysDao, OptionsRecord> implements OptionsRecordService {

    @Resource
    private StudentDao studentDao;
    /**
     * 多条件查询刷题信息
     *
     * @param classId
     * @param courseId
     * @param start
     * @param end
     * @return
     */
    @Override
    public List<SolveTopicVO> getSolveTopicVOList(Integer classId, Integer courseId, Date start, Date end) {
        Map<String,Object> map = new HashMap<>();
        map.put("classId",classId);
        map.put("start",start);
        map.put("end",end);
        return baseMapper.getSolveTopicVOList(map);
    }

    /**
     * 按照章节错误率排名
     *
     * @param courseId
     * @param start
     * @param end
     * @return
     */
    @Override
    public List<Map<String, Object>> getChapterListWrong(Integer courseId, Date start, Date end) {
        Map<String,Object> map = new HashMap<>();
        map.put("courseId",courseId);
        map.put("start",start);
        map.put("end",end);
        /**
         * 获取章节名称和排名
         */
        List<Map<String, Object>> mapList = baseMapper.getChapterListWrong(map);
        return mapList;
    }
}
